<form action="search.php" method="get">
<div class="float-left form">
<div class="float-left h-form">
	<fieldset>
		<legend>Repository</legend>
		<select name="repos[]" multiple class="multi-box" id="sel_repos">
			<?
			$i = 0;
			$num = count($this->repos);
			while($i < $num):
				$selected = null;
				if($num == 1):
					$selected = ' selected';
				endif;
				if(is_array($this->search['repos']) && in_array($this->repos[$i]['id'],$this->search['repos'])):
					$selected = ' selected';
				endif;
			?>
			<option<?=$selected?> value="<?=$this->repos[$i]['id']?>"><?=$this->repos[$i]['name']?></option>
			<?
				++$i;
			endwhile;
			?>
		</select>
	</fieldset>
</div>
<div class="float-left h-form">
	<fieldset>
		<legend>User</legend> 
		<select name="user[]" multiple class="multi-box" id="sel_user">
			<?
			$i = 0;
			$num = count($this->authors);
			if($num > 1):
				if(empty($this->search['user'])):
					$all_selected = ' selected';
				else:
					$all_selected = null;
				endif;
			?>
			<option<?=$all_selected?> value="0">**ALL**</option>
			<?
			endif;
			while($i < $num):
				$selected = null;
				if($num == 1):
					$selected = ' selected';
				endif;
				if(is_array($this->search['user']) && in_array($this->authors[$i]['id'],$this->search['user'])):
					$selected = ' selected';
				endif;
			?>
				<option<?=$selected?> value="<?=$this->authors[$i]['id']?>"><?=$this->authors[$i]['user']?></option>
			<?
				++$i;
			endwhile;
			?>
		</select>
	</fieldset>
</div>
<div class="clear-left"></div>

<div class="form">
	<fieldset>
		<legend>Path</legend>
		<div id="foo"></div>
		<input type="text" name="path" id="tbx_path" class="standard" value="<?=htmlentities($this->search['path'])?>">
		<div>
		<input type="checkbox" id="cbx_only_match" name="only_match"<? if($this->search['only_match']):?> checked<? endif;?>>
		<label for="cbx_only_match">Hide other files in results</label>
		</div>
	</fieldset>
</div>
<div class="form">
	<fieldset>
		<legend>Log</legend>
		<input type="text" name="log" class="standard" value="<?=htmlentities($this->search['log'])?>">
	</fieldset>
</div>
<div class="form">
	<fieldset class="fs-date">
		<legend>Date options</legend>
		<div>
			<input type="radio" name="date_option" id="rdo_hour" 
				value="hour"<? if($this->search['date_option'] == 'hour'):?> checked<? endif;?>>
				<label for="rdo_hour">In the last</label>
					<input type="text" id="tbx_hours" name="hours" value="<?=(int) $this->search['hours']?>" class="short"> hours
		</div>
		<div>
			<input type="radio" name="date_option" id="rdo_day"
				value="day"<? if($this->search['date_option'] == 'day'):?> checked<? endif;?>>
				<label for="rdo_day">In the last day</label>
		</div>
		<div>
			<input type="radio" name="date_option" id="rdo_week"
				value="week"<? if($this->search['date_option'] == 'week'):?> checked<? endif;?>>
				<label for="rdo_week">In the last week</label>
		</div>
		<div>
			<input type="radio" name="date_option" id="rdo_month"
				value="month"<? if($this->search['date_option'] == 'month'):?> checked<? endif;?>>
				<label for="rdo_month">In the last month</label>
		</div>
		<div>
			<input type="radio" name="date_option" id="rdo_year"
				value="year"<? if($this->search['date_option'] == 'year'):?> checked<? endif;?>>
				<label for="rdo_year">In the last year</label>
		</div>
		<div>
			<input type="radio" name="date_option" id="rdo_all"
				value="all"<? if($this->search['date_option'] == 'all'):?> checked<? endif;?>>
				<label for="rdo_all">Since the beginning of time</label>
		</div>
		<div>
			<input type="radio" name="date_option" id="rdo_between"
				value="between"<? if($this->search['date_option'] == 'between'):?> checked<? endif;?>>
				<label for="rdo_between">Between</label>
				<input type="text" name="d1" id="tbx_d1" class="date"
					value="<?if(!empty($this->search['d1'])): echo $this->search['d1']; endif;?>">
				and
				<input type="text" name="d2" id="tbx_d2" class="date" 
					value="<?if(!empty($this->search['d2'])): echo $this->search['d2']; endif;?>">
		</div>
	</fieldset>
</div>

<div class="form center">
	<input type="button" value="Clear" onclick="window.location.href='reset.php'">
	<input type="submit" value="Search">
</div>
</div>

</form>
<div id="div_repo" class="float-left form hide">
	<fieldset>
		<legend>Repo browser</legend>
		<div id="div_repo_b" class="repo-b"></div>
	</fieldset>
</div>
<div class="clear-left"></div>
